package com.dl.mall.controller.admin;

import com.dl.mall.annotation.MethodInfo;
import com.dl.mall.annotation.SaAdminCheckRole;
import com.dl.mall.entity.Category;
import com.dl.mall.service.admin.CategoryService;
import com.dl.mall.utils.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author DL
 * @create 2022-04-11 11:51
 */
@Slf4j
@RestController()
@RequestMapping("/admin/category")
@SaAdminCheckRole(value = {"super","admin","user"})
@Api(tags="管理员分区controller")
public class CategoryController_Admin {

    @Resource
    private CategoryService categoryService;

    @ApiOperation(value="获取所有产品分区信息")
    @MethodInfo
    @GetMapping("/getCategory")
    public Result getCategory(){
        List<Category> category = categoryService.getCategory();
        if (category != null){
            return Result.ok("查询类别成功").data("category", category);
        }else {
            return Result.error("查询类别失败");
        }
    }
}
